/*
 * Copyright (c) 2023. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.gzdh.device.system.model;


import com.baomidou.mybatisplus.annotation.TableId;
import com.gzdh.device.system.entity.SysPermission;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class SysPermissionTreeModel implements Serializable {


    private static final long serialVersionUID = 1L;

    /**
     * 对应SysDepart中的id字段,前端数据树中的key
     */
    private String key;

    /**
     * 对应SysDepart中的id字段,前端数据树中的value
     */
    private String value;

    /**
     * 对应depart_name字段,前端数据树中的title
     */
    private String title;


    private boolean isLeaf;


    private String id;

    private String parentId;

    private String name;

    private String css;

    private String url;

    private Integer type;

    private String permission;

    private Integer sort;

    private String icon;

    private String component;

    private Integer status;

    private Integer hidden;

    private Date createTime;

    private List<SysPermissionTreeModel> children = new ArrayList<>();


    public SysPermissionTreeModel(SysPermission sysPermission) {
        this.key = sysPermission.getId();
        this.value = sysPermission.getId();
        this.title = sysPermission.getName();


        this.id = sysPermission.getId();

        this.parentId = sysPermission.getParentId();

        this.name = sysPermission.getName();

        this.css = sysPermission.getCss();

        this.url = sysPermission.getUrl();

        this.type = sysPermission.getType();

        this.permission = sysPermission.getPermission();

        this.sort = sysPermission.getSort();

        this.icon = sysPermission.getIcon();

        this.component = sysPermission.getComponent();
        this.status = sysPermission.getStatus();
        this.hidden = sysPermission.getHidden();
        this.createTime = sysPermission.getCreateTime();
    }

    public void setChildren(List<SysPermissionTreeModel> children) {
        if (children == null) {
            this.isLeaf = true;
        }
        this.children = children;
    }
}
